@extends('admin.layout')
@section('title','商品列表')
@section('body')

    <div id="search" style="height:63px;">
        <blockquote class="layui-elem-quote" style="font-size: 14px">
            <form action="" method="post" class="layui-form">
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <a href="javascript:history.back()" class="layui-btn layui-btn-small" >返回</a>
                        <div  onclick="ins();" class="layui-btn layui-btn-small" >添加</div>
                    </div>
                </div>
            </form>
        </blockquote>
    </div>
    <table class="layui-table " >
        <colgroup>

        </colgroup>
        <thead>
        <tr>
            <th>账户名</th>
            <th>密码</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($admin as $value)
            <tr @if($value->type==2) onclick="window.location.href='{{url('check/shop')}}?admin_id={{$value->admin_id}}'"  class=" bg-warning "

                    @else
                    class=" bg-info"
                    @endif>
                <td>{{$value->username}}</td>
                <td>{{$value->password}}</td>
                <td>{{$value->created_at}}</td>
                <td >
                    <button  class="btn btn-danger"  onclick="del('{{$value->admin_id}}')">删除</button>

                    <button  class="btn btn-info"  onclick="pwd('{{$value->admin_id}}')">改密</button>
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
@endsection
@section('js')

    <script>
        @if(Session::has('message'))
             layer.msg("{{Session::get("message")}}");
        {{Session::forget('message')}}
        @endif
        function pwd(id) {
            layer.open({
                title:"输入新密码",
                content:'<form id="down" method="post" action="{{url('check/businessman')}}"><input type="hidden" name="admin_id" value="'+id+'"><input placeholder="请输入新密码" type="text" name="password" class="form-control" value="">{{csrf_field()}}</form>',
                yes:function () {
                    $("#down").submit();
                }
            });
            event.stopPropagation();
        }

        function del(id) {
            layer.open({
                title:"提示",
                content:'确定删除?<form id="del" method="post" action="{{url('check/businessman_del')}}"><input type="hidden" name="admin_id" value="'+id+'">{{csrf_field()}}</form>',
                yes:function () {
                    $("#del").submit();
                }
            });
            event.stopPropagation();
        }

        function ins(id) {
            layer.open({
                title:"添加分销商",
                content:'<form id="down" method="post" action="{{url('check/businessman')}}"><input placeholder="用户名" type="text" name="username" class="form-control" value=""><input placeholder="密码" type="text" name="password" class="form-control" value="">{{csrf_field()}}</form>',
                yes:function () {
                    $("#down").submit();
                }
            })
        }

    </script>

@endsection

